package j.framework.core.entity;

/**
 * 这个触发器是针对实体的每个操作进行定义触发器，触发器的实现可分散到各个业务类中，也可以使用sql语句
 * User: jason
 * Date: 2015/4/8 18:10
 */
public class EntityInvokeTrigger implements java.io.Serializable {
    /**
     * 在显示增加实体表单前调用
     */
    public static final int WHEN_INVOKE_AT_SHOW_ADD_FORM = 1;
    /**
     * 在显示修改实体表单前调用
     */
    public static final int WHEN_INVOKE_AT_SHOW_EDIT_FORM = 2;
    public static final int WHEN_INVOKE_AT_BEFORE_INSERT = 4;
    public static final int WHEN_INVOKE_AT_AFTER_INSERT = 8;
    public static final int WHEN_INVOKE_AT_BEFORE_UPDATE = 16;
    public static final int WHEN_INVOKE_AT_AFTER_UPDATE = 32;
    public static final int WHEN_INVOKE_AT_BEFORE_DELETE = 64;
    public static final int WHEN_INVOKE_AT_AFTER_DELETE = 128;
    /**
     * 以sql方式执行
     */
    public static final String EXECUTE_TYPE_SQL = "S";
    /**
     * 以bean方式执行
     */
    public static final String EXECUTE_TYPE_BEAN = "B";

    private String triggerName;

    private int whenTriggerInvoke;

    private String executeTypeId;

    private String namedSql;

    private String beanClassName;

    private String beanMethodName;

    public String getTriggerName() {
        return triggerName;
    }
    public void setTriggerName(String triggerName) {
        this.triggerName = triggerName;
    }

    public int getWhenTriggerInvoke() {
        return whenTriggerInvoke;
    }
    public void setWhenTriggerInvoke(int whenTriggerInvoke) {
        this.whenTriggerInvoke = whenTriggerInvoke;
    }

    public String getExecuteTypeId() {
        return executeTypeId;
    }
    public void setExecuteTypeId(String executeTypeId) {
        this.executeTypeId = executeTypeId;
    }

    public String getNamedSql() {
        return namedSql;
    }
    public void setNamedSql(String namedSql) {
        this.namedSql = namedSql;
    }

    public String getBeanClassName() {
        return beanClassName;
    }
    public void setBeanClassName(String beanClassName) {
        this.beanClassName = beanClassName;
    }

    public String getBeanMethodName() {
        return beanMethodName;
    }
    public void setBeanMethodName(String beanMethodName) {
        this.beanMethodName = beanMethodName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        EntityInvokeTrigger that = (EntityInvokeTrigger) o;

        return !(triggerName != null ? !triggerName.equals(that.triggerName) : that.triggerName != null);

    }

    @Override
    public int hashCode() {
        return triggerName != null ? triggerName.hashCode() : 0;
    }
}
